// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <sstream>
#include <string>

namespace kumo::pollux {
    /**
     * Contains the types of vector encodings available for various classes of
     * vectors.
     */
    namespace VectorEncoding {
        /**
         * Provides an enumeration of vector encoding types.
         */
        enum class Simple {
            BIASED,
            CONSTANT,
            DICTIONARY,
            FLAT,
            SEQUENCE,
            ROW,
            MAP,
            ARRAY,
            LAZY,
            FUNCTION
        };

        inline std::ostream &operator<<(
            std::ostream &out,
            const VectorEncoding::Simple &type) {
            switch (type) {
                case VectorEncoding::Simple::BIASED:
                    return out << "BIASED";
                case VectorEncoding::Simple::CONSTANT:
                    return out << "CONSTANT";
                case VectorEncoding::Simple::DICTIONARY:
                    return out << "DICTIONARY";
                case VectorEncoding::Simple::FLAT:
                    return out << "FLAT";
                case VectorEncoding::Simple::SEQUENCE:
                    return out << "SEQUENCE";
                case VectorEncoding::Simple::ROW:
                    return out << "ROW";
                case VectorEncoding::Simple::MAP:
                    return out << "MAP";
                case VectorEncoding::Simple::ARRAY:
                    return out << "ARRAY";
                case VectorEncoding::Simple::LAZY:
                    return out << "LAZY";
                case VectorEncoding::Simple::FUNCTION:
                    return out << "FUNCTION";
            }
            return out;
        }

        inline std::string mapSimpleToName(const VectorEncoding::Simple &simple) {
            std::stringstream ss;
            ss << simple;
            return ss.str();
        }

        inline bool isFlat(VectorEncoding::Simple encoding) {
            return encoding == VectorEncoding::Simple::FLAT;
        }

        inline bool isConstant(VectorEncoding::Simple encoding) {
            return encoding == VectorEncoding::Simple::CONSTANT;
        }

        inline bool is_lazy(VectorEncoding::Simple encoding) {
            return encoding == VectorEncoding::Simple::LAZY;
        }

        inline bool isDictionary(VectorEncoding::Simple encoding) {
            return encoding == VectorEncoding::Simple::DICTIONARY;
        }

        VectorEncoding::Simple map_name_to_simple(const std::string &name);
    } // namespace VectorEncoding
} // namespace kumo::pollux
